//
//  UIImage+Extension.h
//  TableDemo
//
//  Created by jutuo on 2020/3/26.
//  Copyright © 2020 jutuo. All rights reserved.
//


#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger,GradientDirectionType) {
    GradientLeftToRight = 0,
    GradientLeftTopToRightBottom,
    GradientLeftBottomToRightTop,
    GradientRightToLeft,
    GradientRightTopToLeftBottom,
    GradientRightBottomToLeftTop,
    GradientTopToBottom,
    GradientBottomToTop,
};
@interface UIImage (Extension)
/**
 *根据颜色返回图片
 */
+ (nullable UIImage *)imageWithColor:(UIColor *)color;
+ (nullable UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;
/**
 * 返回渐变颜色的图片
 */
+ (UIImage *)gradientImageWithPath:(CGPathRef)path colors:(NSArray*)colors gradientDirectionType:(GradientDirectionType)gradientDirection;

+ (UIImage *)gradientImageWithRect:(CGRect)rect colors:(NSArray*)colors gradientDirectionType:(GradientDirectionType)gradientDirection;

+ (UIImage *)imageWithEmoji:(NSString *)emoji size:(CGFloat)size;
+ (UIImage *)imageWithPDF:(id)dataOrPath page:(size_t)pageNum;
+ (UIImage *)imageWithPDF:(id)dataOrPath size:(CGSize)size page:(size_t)pageNum;


// 截取部分图像
- (UIImage *)cutOutSubImage:(CGRect)rect;
- (UIImage *)imageByTintColor:(UIColor *_Nullable)color;
- (UIImage *)imageByTintColor:(UIColor *_Nullable)color size:(CGSize)size;
- (UIImage *)imageByResizeToSize:(CGSize)size;
- (UIImage *)imageByScale:(CGFloat)scale;
- (UIImage *)imageByInsetEdge:(UIEdgeInsets)insets withColor:(UIColor *)color;

/**
 添加圆角
 */
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius;
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius
borderWidth:(CGFloat)borderWidth
                          borderColor:(UIColor * _Nullable)borderColor;

- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius
       corners:(UIRectCorner)corners
   borderWidth:(CGFloat)borderWidth
   borderColor:(UIColor *_Nullable)borderColor
                       borderLineJoin:(CGLineJoin)borderLineJoin;

/**
 获取网络视频的任意时间帧图片
 */
+ (void)imageByVideoUrl:(NSURL *)videoURL atTime:(NSTimeInterval)time completion:(void (^)(UIImage*))handler;
@end


@interface UIImage (Gif)
/**
 * 获取gif图片
 * @param data gif data;
 */
+ (UIImage *)getGifImageWithGIFData:(NSData *)data scale:(CGFloat)scale;
/**
 * 获取gif图片
 * @param url gif url;
 */
+ (UIImage *)getGifImageWithGIFURL:(NSURL *)url scale:(CGFloat)scale;
@end
NS_ASSUME_NONNULL_END
